﻿
var dbase;

function init()
{
	dbase = _server.getDatabaseManager();
}

function destroy()
{
	
}

function handleRequest(cmd, params, user, fromRoom)
{
	switch(cmd){
		case "association_list_cmd":
			getAssociationList(cmd, params, user, fromRoom);//获取个人信息
			break;
	}
}

function handleInternalEvent(evt)
{
	
}

function getAssociationList(cmd, params, user, fromRoom){
	
	var t1 = getTimer();
	
	var sql = "select * from pvs.association";
	var queryRes = dbase.executeQuery(sql);
	
	var t2 = getTimer();
	//trace("DB Request took: " + (t2-t1) + " ms.");
	
	var response = {};
	response._cmd=cmd;
	response.association_list = [];

	if (queryRes != null)
	{
		for(var i = 0;i<queryRes.size();i++){
			var tempRow = queryRes.get(i);
			var item = {};
			item.id  = tempRow.getItem("id");
			item.name= tempRow.getItem("name");
			item.desc= tempRow.getItem("desc");
			response.association_list.push( item );
		}
	}
	else
	{
		trace("DB Query failed");
	}
	_server.sendResponse(response, -1, null, [user],"xml");
}
